package com.zzyd.factory.net.mainmsg;

import android.util.Log;

import com.zzyd.common.mvp.data.DataSource;
import com.zzyd.factory.data.market.MarketBean;
import com.zzyd.factory.net.DataNetApi;
import com.zzyd.factory.net.NetWork;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * @author wjunjie
 * @version 1.0
 * @E-mail wang_junjie007@163.com
 * @company ZZYD
 * @createTime 2018/8/28 17:09
 * @类注释:
 */
public class MsgInfoHelper {

    public static void getMsg(String coinId, final DataSource.CallBack<MarketBean> dataCallback) {
        DataNetApi dataNetApi = NetWork.getRetrofit().create(DataNetApi.class);
        Call<MarketBean> beanCall = dataNetApi.marketMsg(coinId);
        beanCall.enqueue(new Callback<MarketBean>() {
            @Override
            public void onResponse(Call<MarketBean> call, Response<MarketBean> response) {
                if (dataCallback != null && response.body() != null) {
                    dataCallback.onDataLoaded(response.body());
                }
            }

            @Override
            public void onFailure(Call<MarketBean> call, Throwable t) {
                Log.e("ERROR", t.getMessage());
            }
        });
    }
}
